package com.gin.supermarket_inventory_system.commodity.dto.form;

import com.gin.database.validation.EntityId;
import com.gin.supermarket_inventory_system.commodity.entity.CommodityTypePo;
import com.gin.supermarket_inventory_system.commodity.service.CommodityTypeService;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Getter;
import lombok.Setter;
import org.springframework.beans.BeanUtils;

/**
 * 修改商品类型
 * @since : 2023/10/9 15:03
 * @author : ginstone
 * @version : v1.0.0
 **/
@Getter
@Setter
@Schema(description = "表单对象:修改商品类型")
public class CommodityTypeUpdateForm {
    @EntityId(service = CommodityTypeService.class)
    @NotNull
    long id;

    @Schema(description = "名称")
    @NotEmpty
    String name;

    @Schema(description = "父类型ID")
    @EntityId(service = CommodityTypeService.class, nullable = true)
    Long parentId;

    public CommodityTypePo toPo() {
        final CommodityTypePo po = new CommodityTypePo();
        BeanUtils.copyProperties(this, po);
        return po;
    }
}